package com.baizan.daka.ui.presenter

import com.baizan.daka.base.BasePresenter
import com.baizan.daka.ui.contract.TaskingContract
import com.baizan.daka.mvp.model.MyTaskModel
import com.baizan.daka.mvp.model.bean.TaskInfoBean
import com.baizan.daka.net.BasePageResponse
import com.baizan.daka.rx.Subscriber.CommonSubscriber
import com.baizan.daka.showToast

class TaskingPresenter(val mView: TaskingContract.View) : BasePresenter(),
    TaskingContract.Presenter {
    val taskModel: MyTaskModel by lazy { MyTaskModel() }

    override fun loadList(CurrentPage: Int) {
        mView.showLoadingDialog()
        taskModel.taskingList(CurrentPage,1)
            .subscribe(object :
                CommonSubscriber<BasePageResponse<TaskInfoBean>>(compositeDisposable) {

                override fun onCallNext(t: BasePageResponse<TaskInfoBean>?) {
                    mView.loadListSuccess(t!!)
                }

                override fun onCallError(e: String) {
                    super.onCallError(e)
                    showToast(e)
                }

                override fun onCallCompleted() {
                    super.onCallCompleted()
                    mView.hideLoadingDialog()
                }
            })

    }


}

